<template>
  <div>

    <!-- 条件搜托条 -->
    <div class="topSearch">
      <div class="leftBox">
        <div class="searchbox">
        <em>电子印章名称</em>
        <el-input v-model="searchBox.sealName" size="small" style="width:250px" placeholder="请输入电子印章名称"></el-input>
        </div>
        <div class="searchbox">
        <el-button type="primary" size="mini" @click="getList">搜索</el-button>
        </div>
      </div>
      <div class="rightBox">
         <el-button type="primary" size="mini" @click="addNew">添加电子印章</el-button>
      </div>
      <div class="clear"></div>
    </div>

    <!-- 列表内容↓ -->
    <div class="contentBox">
      <el-table :data="sealList" :header-cell-style="headClass" border stripe style="width: 100%" height="90%">
        <el-table-column prop="name" label="电子印章名称"></el-table-column>
        <el-table-column prop="createName" label="添加人"></el-table-column>
        <el-table-column prop="createTime" label="添加时间"></el-table-column>
        <el-table-column fixed="right" width="250" label="操作">
          <template slot-scope="scope">
            <el-button  @click="watchDetail(scope.row)" type="primary" size="mini">查看</el-button>
            <el-button :disabled="scope.row.isUse" @click="changeSeal(scope.row)" type="primary" size="mini">修改</el-button>
            <el-button :disabled="scope.row.isUse"  @click="drop(scope.row)" type="danger" size="mini">删除</el-button>
          </template>
        </el-table-column>
    </el-table>
    <div class="paging">
      <el-pagination background layout="total, prev, pager, next" @current-change="handleCurrentChange" :current-page.sync="pageIndex" :total="pageAll"></el-pagination>
    </div>
    </div>

    <!-- 弹层内容↓ -->


  </div>
</template>

<script>
export default {
  data() {
    return {
      ccc:'电子印章管理',
      searchBox:{
        sealName:'',
      },
      sealList:[],
      pageAll:0,
      pageIndex:0,
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 头部样式
    headClass:function(){
      return 'text-align: center;'
    },
    // 获取印章泪列表
    getList:function(){
      this.$api.systemSetup.GetElectronicSealList(this.searchBox.sealName,this.pageIndex).then(res=>{
        //console.log("获取印章列表",res);
        this.sealList = res.data.result.list;
        this.pageAll = res.data.result.total;
        this.pageIndex = res.data.result.page;
      })
    },
    // 修改电子印章
    change:function(obg){
      this.$router.push({name:'ElectronicSealDetails',params:{flag:"EDIT",sealId:obg.id}});
    },
    // 删除印章
    drop:function(obg){

      this.$confirm('确定删除当前电子印章？','提示',{
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(()=>{
        this.$api.systemSetup.DropElectronicSeal(obg.id).then(res=>{
          //console.log("删除印章",res);
            if(res.data.status=='SUCCESS'){
              this.$message({
                  message:'删除成功!',
                  type: 'success'
              })
              this.getList();
            }else{
              this.$message.error(res.data.message);
            }
        })
      }).catch(()=>{
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    // 点击新增印章
    addNew:function(){
      this.$router.push({name:'ElectronicSealDetails',params:{flag:"ADD",ftype:"add"}});
    },
    // 查看印章详情
    watchDetail:function(obg){
      this.$router.push({name:'ElectronicSealDetails',params:{sealId:obg.id,ftype:"watch"}});
    },
    // 修改印章内容
    changeSeal:function(obg){
      this.$router.push({name:'ElectronicSealDetails',params:{sealId:obg.id,flag:"EDIT",ftype:"change"}});
    },
    handleCurrentChange:function(size){
      this.pageIndex = size;
      this.getList();
    }
  }
}
</script>
